﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FONCREAGROINTEGRAL.Models;

namespace FONCREAGROINTEGRAL.Controllers
{
    public class categoriasemovienteController : Controller
    {
        public SistIntFoncreagroEntities entidades = new SistIntFoncreagroEntities();
        //
        // GET: /categoriasemoviente/

        public ActionResult Index(int id)
        {
            int start = Convert.ToInt32(Request.QueryString["start"]);
            int limit = Convert.ToInt32(Request.QueryString["limit"]);

            var query = entidades.INVListCategoriaSemoviente(id).ToList();

            return Json(new { grid = query.Skip(start).Take(limit), total = query.Count() }, JsonRequestBehavior.AllowGet);
        }

        //
        // GET: /categoriasemoviente/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /categoriasemoviente/Create

        //public ActionResult Create()
        //{
        //    return View();
        //} 

        //
        // POST: /categoriasemoviente/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            String strResponse = String.Empty;
            try
            {
                // TODO: Add insert logic here

                strResponse = "{success: true,msg:'<b>Se Pago CTS Empleados y Obreros</b>'}";
                return Content(strResponse);
            }
            catch (Exception e)
            {
                string sms = e.Message;
                strResponse = "{success: false,msg:\"" + sms + "\"}";
                return Content(strResponse);
            }
        }
        
        //
        // GET: /categoriasemoviente/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /categoriasemoviente/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /categoriasemoviente/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /categoriasemoviente/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
